package zjut.cocouml.command;

import org.eclipse.gef.commands.Command;

import zjut.cocouml.model.BAttribute;

public class BAttributeModifyCommand extends Command {
	
	private BAttribute model;
	
	private String oldAttrName;
	private String newAttrName;
	
	private String oldAccessAuthrity;
	private String newAccessAuthrity;
	
	private String oldType;
	private String newType;
	
	private boolean oldFinal;
	private boolean newFinal;
	
	private boolean oldStatic;
	private boolean newStatic;
	
	public void execute() {
		this.oldAttrName = model.getAttrName();
		this.oldAccessAuthrity = model.getAccessAuthrity();
		this.oldType = model.getType();
		this.oldFinal = model.isFinal();
		this.oldStatic = model.isStatic();
		
		model.setAttrName(newAttrName);
		model.setAccessAuthrity(newAccessAuthrity);
		model.setType(newType);
		model.setFinal(newFinal);
		model.setStatic(newStatic);
		
		this.model.setDisplayName(model.getDisplayName());
		System.out.println("BAttributeModifyCommand ================== model name ========== "+this.model.getDisplayName());
	}

	public void undo() {
		model.setAttrName(this.oldAttrName);
		model.setAccessAuthrity(this.oldAccessAuthrity);
		model.setType(this.oldType);
		model.setFinal(this.oldFinal);
		model.setStatic(this.oldStatic);
		this.model.setDisplayName(model.getDisplayName());
	}
	public void setNewAttrName(String newAttrName) {
		this.newAttrName = newAttrName;
	}
	public void setNewType(String newType) {
		this.newType = newType;
	}
	public void setNewFinal(boolean newFinal) {
		this.newFinal = newFinal;
	}
	public void setNewStatic(boolean newStatic) {
		this.newStatic = newStatic;
	}
	public void setModel(Object model) {
		this.model = (BAttribute)model;
	}
	public void setNewAccessAuthrity(String newAccessAuthrity) {
		this.newAccessAuthrity = newAccessAuthrity;
	}
	

}
